//--------------------------------------------------------------------
//
//  Laboratory 4                                           ordlist.h
//
//  Class declaration for the array implementation of the Ordered
//  List ADT -- inherits the array implementation of the List ADT
//  (Laboratory 3)
//
//--------------------------------------------------------------------

#ifndef ORDLIST_H
#define ORDLIST_H

#include <stdexcept>

#include "listarr2.cpp"

template < class DT >
class OrdList : public aList<DT>
{
  public:

    // Constructor
    OrdList ( int maxNumber = defMaxListSize );

    // Modified (or new) list manipulation operations
    virtual void insert ( const DT &newDataItem );
        //throw ( logic_error );
    virtual void replace ( const DT &newDataItem );
        //throw ( logic_error );
    bool retrieve ( int searchKey, DT *&searchDataItem );

    // Output the list structure -- used in testing/debugging
    void showStructure () const;

  private:

    // Locates an element (or where it should be) based on its key
    bool binarySearch ( int searchKey, int &index );
};

#endif // #ifndef ORDLIST_H

